#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char c[40001][40001];
struct node1
		{
			int a;
			int b;
		};
struct node2
		{
			int a;
			int b;
		};
bool cmp1(node1 x, node1 y)
{
	return x.a<y.a;
}
bool cmp2(node2 x, node2 y)
{
	return x.a<y.a;
}

int main()
{
	
	int t;
	scanf("%d",&t);
	while(t--)
	{
		
		int n,m;
		node1 line[40001];
		node2 rank[40001];
		memset(line,0,sizeof(line));
		memset(rank,0,sizeof(rank));
		scanf("%d %d",&n,&m);
		for(int i = 0;i<n;i++)
		for(int j = 0;j<m;j++)
		{
			scanf(" %c",&c[i][j]);
			if(c[i][j]=='.')
			{
				line[i].a++;
				rank[j].a++;	
			}
			line[i].b = i;
			rank[j].b = j;
		}
		
		sort(line,line+n,cmp1);
		sort(rank,rank+m,cmp2);
	
		if(c[line[0].b][rank[0].b]=='*')
		{
			printf("%d\n",line[0].a+rank[0].a);
			
		}
		else 
		{
			printf("%d\n",line[0].a+rank[0].a-1);
		}
	}
}
